import { response } from "express"
import { request } from "express"
import BreedService from "../../service/breedService/breedService.js";

class BreedController {
    /**
     * @param {request} req
     * @param {response} res
     */
    static async InsertBreedList(req, res, next) {
        try {
            const modelArray = req.body;
            const status = await BreedService.InsertBreedList(modelArray)
            if (status) {
                res.send({
                    msg: '添加成功',
                    code: 1,
                    data: status
                })
            } else next({ msg: '添加失败' })
        } catch (error) {
            next({ error })
        }
    }
    /**
     * @param {request} req
     * @param {response} res
     * get请求响应
     */
    static async GetAllList(req, res, next) {
        try {
            const result = await BreedService.GetAllList()
            res.send({
                msg: '查询成功',
                code: 1,
                data: result
            }).end()
        } catch (error) {
            next({ error })
        }
    }
}

export default BreedController